import request from './request.js'

export function getUsersListService(params) {
    return request({
        url: 'users',
        method: 'get',
        params: params
    })
}

export function changeUserStatus(params) {
    return request({
        url: 'users' + params,
        method: 'put'
    })
}

export function saveUserService(params) {
    if (params.id !== 0) return EditUserService(params)
    else return addUserService(params)
}

function addUserService(params) {
    return request({
        url: 'users',
        method: 'post',
        data: params
    })
}

function EditUserService(params) {
    return request({
        url: 'users/' + params.id,
        method: 'put',
        data: params
    })
}

export function getUserByIdService(params) {
    return request({
        url: 'users/' + params,
        method: 'get'
    })
}

export function deleteUserByIdService(id) {
    return request({
        url: 'users/' + id,
        method: 'delete'
    })
}
